home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / brnout23.arc / BURNOUT.ASM < prev    next >
Assembly Source File  |  1988-03-29  |  4KB  |  158 lines

  1. Comment *
  2.  
  3.         BURNOUT by Chris Dunford - demo program to
  4.         access/change/display BRNDEV parameters.
  5.  
  6.         To use, just type:
  7.  
  8.             BURNOUT parameters
  9.  
  10.         where the parameters are anything that's legal as a BRNDEV
  11.         option (as described in the documentation).  For example:
  12.  
  13.             BURNOUT 5000
  14.             BURNOUT 5000 H- F7
  15.  
  16.         Preparation:
  17.             MASM burnout;
  18.             LINK burnout;     [ignore NO STACK message]
  19.             EXE2BIN burnout burnout.com
  20.  
  21.         Revised 23-Dec-1987 because I lost the source for the original.
  22.  
  23. *
  24.  
  25. ; ---------------------------------------------------------
  26. ; DEFINITIONS section
  27. ;
  28.  
  29. ; DOS functions we'll use
  30. PRINT   equ 9                           ; Print a string$
  31. FOPEN   equ 3DH                         ; Open a file/device
  32. FREAD   equ 3FH                         ; Read from a file/device
  33. FWRITE  equ 40H                         ; Write to a file/device
  34. EXIT    equ 4CH                         ; Exit to DOS
  35.  
  36. ; A couple of ASCII characters
  37. LF      equ 10
  38. CR      equ 13
  39.  
  40. ; Macro to access DOS functions
  41. DOS macro func
  42.         mov ah,func
  43.         int 21H
  44. endm
  45.  
  46.  
  47. code segment
  48. assume cs:code, ds:code, es:code
  49.  
  50. ; Where the commandline parameters will go (in the PSP)
  51.  
  52. org 80H
  53. parm_len    label byte                  ; Parameter length attribute
  54.  
  55. org 81H
  56. parms       label byte                  ; Parameter text
  57.  
  58. ; Program entry point
  59. org 100H
  60. burnout:
  61.         jmp start                       ; Jump to code
  62.  
  63.  
  64. ; ------------------------------------------------------------------
  65. ; DATA section
  66. ;
  67.  
  68. ; BURNOUT system device name (ASCIIZ format)
  69. devname         db 'BRNDEV',0
  70.  
  71. ; BRNDEV's reset and execute characters
  72. reset           db '@'
  73. execute         db '#'
  74.  
  75. ; Message displayed if BRNDEV isn't installed
  76. not_installed$  db 'Burnout device is not installed',CR,LF,'$'
  77.  
  78. ; Status report message, followed IMMEDIATELY by the buffer
  79. ; into which the BRNDEV status report is read.  These are
  80. ; displayed in one operation, so don't separate the two.
  81. status$         db 'Current status: '
  82. buffer          db 15 dup (0)
  83.  
  84. ; -------------------------------------------------------------
  85. ; CODE section
  86. ;
  87.  
  88. start:
  89.  
  90. ; See if BRNDEV is installed
  91.         mov dx,offset devname           ; File name is 'BRNDEV'
  92.         mov al,2                        ; Open for read/write
  93.         DOS fopen
  94.         jnc rewind                      ; If no carry, BRNDEV is installed
  95.  
  96. ; BURNOUT isn't installed
  97.         mov dx,offset not_installed$    ; Display error message
  98.         DOS print
  99.         mov al,1                        ; Exit with errorlevel 1
  100.         jmp bye
  101.  
  102. ; It's installed.  Send a '@' to the device.  This prepares
  103. ; the device for accepting new operating parameters and it
  104. ; places the current BRNDEV status into BRNDEV's I/O buffer.
  105. ; If there are no command line options, we'll go directly
  106. ; to the READ portion, and the status report will be current.
  107. rewind:
  108.         mov bx,ax
  109.         mov dx,offset reset
  110.         mov cx,1
  111.         DOS fwrite
  112.  
  113. ; If there are command line parameters, send them to the device.
  114.  
  115.         ; No options if parm length is zero
  116.         mov al,parm_len
  117.         or al,al
  118.         jz get_status
  119.  
  120.         ; Write options to the device
  121.         cbw                             
  122.         mov cx,ax                       ; CX = parameter length
  123.         mov dx,offset parms
  124.         DOS fwrite
  125.  
  126.         ; Send a '#' to force parsing of the options we just sent.
  127.         ; This also updates the status report in the BRNDEV i/o buffer.
  128.         mov dx,offset execute
  129.         mov cx,1
  130.         DOS fwrite
  131.  
  132. ; Read and display current BRNDEV status
  133. get_status:
  134.  
  135.         ; Read from device into our buffer
  136.         mov dx,offset buffer
  137.         mov cx,255
  138.         DOS fread
  139.  
  140.         ; Add an LF and a '$' to what BRNDEV sent
  141.         mov di,dx                           ; DI -> start to status report
  142.         add di,ax                           ; DI -> end of report (past CR)
  143.         mov word ptr [di],'$' shl 8 + LF    ; Put LF + '$' there for DOS fn 9
  144.  
  145.         ; Display the results
  146.         mov dx,offset status$
  147.         DOS print
  148.  
  149.         ; Errorlevel 0
  150.         xor al,al
  151.  
  152. ; Common exit.  AL should have errorlevel at this point.
  153. bye:
  154.         DOS exit
  155.  
  156. code ends
  157. end burnout
  158.